<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
            <title>
            </title>
            <link href="__LAYUI__/css/layui.css" rel="stylesheet" type="text/css"/>
            <script src="__LAYUI__/layui.js" type="text/javascript">
            </script>
            <script src="__STATIC__/js/form.js" type="text/javascript">
            </script>
        </meta>
    </head>
    <body>
        <form class="layui-form" name="categoryForm" style="margin: 20px 50px;">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    分类名称
                </label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="required" name="name" type="text">
                    </input>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    排序
                </label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="required" name="sort" type="text">
                    </input>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    状态
                </label>
                <div class="layui-input-block">
                    <input checked="" name="status" title="启用" type="radio" value="1"></input>
                    <input name="status" title="禁用" type="radio" value="0"></input>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                        <input name="id" style="display: none;" type="text">
                        <button class="layui-btn layui-btn-normal" lay-filter="category" lay-submit="">
                            提交
                        </button>
                    </input>
                </div>
            </div>
        </form>
        <script type="text/javascript">
            var formObj = new Form('categoryForm');
                formObj.init({$category});

            layui.use(['form','layer'], function(){
                var $ = layui.jquery;
                var layer = layui.layer;
                var form = layui.form();

            form.on('submit(category)', function(e){
                $.post("{:url('admin/Article/editCategory')}", e.field, function(res){
                    if(res.status == 1){
                      layer.msg(res.msg,{time:1000},function(){
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                        parent.location.reload();
                      });
                    }else{
                      layer.msg(res.msg);
                    }
                },'json');
                return false;
            });

            });
        </script>
    </body>
</html>
